package com.leo.springbootmultithreadbasic.lock.reentranreadwritelock.readread;

/**
 * @author Leo
 * @version V1.0
 * @date 2021/11/5 10:31 PM
 */
public class MainDemo {
    public static void main(String[] args) {
        testReadRead();
    }


    /**
     * Test Result:
     * 多个线程几乎同时获得读锁，体现了读锁读锁之间的共享
     * 提高了程序允许效率
     */
    public static void testReadRead() {
        MyService myService = new MyService();

        // build thread
        for (int i = 0; i < 5; i++) {
            Thread thread = new Thread(new MyRunnable(myService));
            thread.setName(String.valueOf(i));
            thread.start();
        }
    }
}
